import { GetProjectById, UpdateProject } from "@/api/projects"; import { PrimaryButton } from "@/components/Button"; import MainLayout from "@/components/MainLayout"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; const UpdateProjectPage = () => { const router = useRouter(); const { id } = router.query; const [project, setProject] = useState(); useEffect(() => { GetProjectById(id ? id.toString() : "", setProject); }, [id]); const [name, setName] = useState(project?.data?.name || ""); const [apiResponse, setApiResponse] = useState(); async function formSubmit(e: React.FormEvent) { e.preventDefault(); let project = { Name: name, Id: id }; UpdateProject(project, setApiResponse); } useEffect(() => { apiResponse && apiResponse.status === "OK" && router.push("/projects"); }, [apiResponse]); useEffect(() => { setName(project?.data?.name || ""); }, [project]); return (

Update Project

setName(e.target.value)} className="w-80 border border-slate-200 p-1" />
); }; export default UpdateProjectPage;